/*
 * Copyright 2012 NJUT  qixiaobo. All rights reserved.
 */
package com.fujitsu.nanjing.tieba.controller.section;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.fujitsu.nanjing.tieba.base.BaseController;
import com.fujitsu.nanjing.tieba.domain.SectionInfo;
import com.fujitsu.nanjing.tieba.exception.Resource404Exception;
import com.fujitsu.nanjing.tieba.service.SectionInfoService;

/**
 * SectionController.java
 * 
 * @author Qixiaobo-win8
 */
@Controller
@RequestMapping("/forum/sections")
public class SectionController extends BaseController {
	@Autowired
	private SectionInfoService sectionInfoService;

	@RequestMapping("/{sectionid}")
	public String showSection(Model model, @PathVariable String sectionid)
			throws Resource404Exception {
		SectionInfo sectioninfo = sectionInfoService.findById(sectionid);
		if (sectioninfo == null) {
			throw new Resource404Exception("分区" + sectionid + "不存在!");
		}
		model.addAttribute("sectionInfo", sectioninfo);
		return "section/section";
	}
}
